package com.cms.rxjava.interval

import com.alibaba.android.arouter.facade.annotation.Route
import com.android.baselibrary.base.BaseDBFragment
import com.cms.rxjava.R
import com.cms.rxjava.databinding.FragmentRxIntervalBinding
import com.cms.rxjava.router.RxRouter
import io.reactivex.Observable
import io.reactivex.disposables.Disposable
import java.util.concurrent.TimeUnit

@Route(path = RxRouter.RxJava_Interval_fragment)
class IntervalFragment : BaseDBFragment<FragmentRxIntervalBinding>(R.layout.fragment_rx_interval) {
    var dispose:Disposable?=null
    override fun initView() {

        mBinding.btnClick.setOnClickListener {
             dispose =  Observable.interval(3,TimeUnit.SECONDS)
                .subscribe { t -> mBinding.number = "$t" }

        }

    }

    override fun onPause() {
        super.onPause()
        dispose?.dispose()
    }
}